package com.gtt.lazy.service.impl;

import java.util.List;

import org.apache.log4j.Logger;

import com.gtt.lazy.domain.ColorCategory;
import com.gtt.lazy.service.ColorCategoryService;
import com.gtt.lazy.util.HibernateTemplateUtil;

/**
 * 色板类别管理类实现
 * 
 * @author 高甜甜
 * @date 2009-9-26
 */
public class ColorCategoryServiceImpl implements ColorCategoryService {

	private static final Logger logger = Logger
			.getLogger(ColorCategoryServiceImpl.class);

	private HibernateTemplateUtil hibernateTemplateUtil;

	public int add(ColorCategory colorCat) {
		if (logger.isDebugEnabled())
			logger.debug("add ColorCategory");
		return (Integer) hibernateTemplateUtil.save(colorCat);
	}

	public void delete(int id) {
		if (logger.isDebugEnabled())
			logger.debug("delete ColorCategory [" + id + "]");
		hibernateTemplateUtil.delete(ColorCategory.class, id);
	}

	public ColorCategory get(int id) {
		return (ColorCategory) hibernateTemplateUtil.get(ColorCategory.class,
				id);
	}

	@SuppressWarnings("unchecked")
	public List<ColorCategory> list() {
		String hql = "from ColorCategory as cc order by cc.id";
		return hibernateTemplateUtil.find(hql);
	}

	public void setHibernateTemplateUtil(
			HibernateTemplateUtil hibernateTemplateUtil) {
		this.hibernateTemplateUtil = hibernateTemplateUtil;
	}
}
